<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
    <link rel="stylesheet" href="./css/bootstrap.css"> 
    <link rel="stylesheet" href="./css/common.css">
    <link rel="stylesheet" href="./css/pading.css">

	<script src="./js/jquery-3.4.1.min.js"></script>  
    <script src="./js/bootstrap.js"></script>
    <title>留言动态-猎狐人才资源服务有限公司</title>
</head>
<body>
	   <div class="wrap hdjl">
        <div class="title clearfix">
            <a class="lf" href="javascript:void(0)"><span>领导信箱</span></a>
            <span id="slsl"></span>
            <a class="rt" href="http://www.cq.gov.cn/publicmail/Citizen/MailSearch.aspx" target="_blank"><img src="../images/xjcx.png" /><span>信件查询</span></a>
            <a class="rt" href="http://www.cq.gov.cn/publicmail/citizen/WriteMail.aspx?intOrganizationID=10010" target="_blank"><img src="../images/wyxx.png" /><span>我要写信</span></a>
        </div>
        <div class="hdjl-table">
            <div class="t-head clearfix">
                <div class="lf t-title"><b>主题</b></div>
                <div class="lf t-zh"><b>邮件字号</b></div>
                <div class="lf t-q-time"><b>来信日期</b></div>
                <div class="lf t-a-time"><b>回复日期</b></div>
            </div>
            <div id="szxxlist">
                <!-- 来信内容 -->
            </div>
        </div>
        <div class="pagination mt20" id="page_hd">
  </div>
</div>


  </div>
<script>
//wcm分页，总记录：
createPage(1, 0, "index", "html");
function createPage(_nPageCount, _nCurrIndex, _sPageName, _sPageExt) {
    
    var page="";
    <!-- 总页数小于一页不显示 -->
    if (_nPageCount == null || _nPageCount <= 1) {
        return false;
    } 

    <!-- 上一页 -->
    if (_nCurrIndex > 0){
        if (_nCurrIndex == 1){
            var prePage = _sPageName + "." + _sPageExt;
        } else {
            var prePage = _sPageName + "_" + (_nCurrIndex - 1) + "." + _sPageExt;
        }
        page+='<a class="first-page" href="' + prePage + '">上一页</a>';
    }
    
    <!-- 前面大于三页 -->
    if (_nCurrIndex > 2) {
        page+='<a class="" href="' + _sPageName + "." + _sPageExt  + '">1</a>'; 
    }
    
    <!-- 前面大于四页省略 -->
    if (_nCurrIndex > 3) {
        page+='<a>...</a>';
    }
    
    <!-- 列表 -->
    for(var i = 0; i < _nPageCount; i++){
        var sPageName;
        <!-- 前两页 -->
        if ((_nCurrIndex - 2) >= 0) { 
            if (i == (_nCurrIndex - 2)){
             if (i == 0) {
                 sPageName = _sPageName + "." + _sPageExt;
             } else {
                 sPageName = _sPageName + "_" + (_nCurrIndex - 2) + "." + _sPageExt;
             }
             page+='<a class="" href="' + sPageName + '">' + ( i + 1 ) +'</a>';
            } 
        }
        if ((_nCurrIndex - 1) >= 0) {
             if (i == (_nCurrIndex - 1)){
                 if (i == 0) {
                     sPageName = _sPageName + "." + _sPageExt;
                 } else {
                     sPageName = _sPageName + "_" + (_nCurrIndex - 1) + "." + _sPageExt;
                 }
                 page+='<a class="" href="' + sPageName + '">' + ( i + 1 ) +'</a>';
             } 
        }
        
        <!-- 当前页 -->
        if(i == _nCurrIndex){
            page+='<a class="active">' + (i + 1) + '</a>';
        }
        
        <!-- 后两页 -->
        if ((_nCurrIndex + 1) <= (_nPageCount - 1)) { 
             if (i == (_nCurrIndex + 1)){                               
                 sPageName = _sPageName + "_" + (_nCurrIndex + 1) + "." + _sPageExt;
                 page+='<a class="" href="' + sPageName + '">' + ( i + 1 ) +'</a>';
             } 
        }
        if ((_nCurrIndex + 2) <= (_nPageCount - 1)) {
             if (i == (_nCurrIndex + 2)){
                 sPageName = _sPageName + "_" + (_nCurrIndex + 2) + "." + _sPageExt;
                 page+='<a class="" href="' + sPageName + '">' + ( i + 1 ) +'</a>';
             } 
        }
              
    }

        for(var j = _nCurrIndex+3 ;j<( _nPageCount>5?5:_nPageCount); j++){
             sPageName = _sPageName + "_" + j + "." + _sPageExt;
         page+='<a class="" href="' + sPageName + '">' + (j+1) +'</a>';
                    
        }


        
    <!-- 后面大于四页省略 -->
    if (_nCurrIndex < (_nPageCount - 4)&&_nPageCount>6) {
        page+='<a>...</a>';
    }
    
    <!-- 后面大于三页 -->
    if (_nCurrIndex <_nPageCount-3&&_nPageCount>5) {
        page+='<a class="" href="' + _sPageName + "_" + (_nPageCount - 1) + "." + _sPageExt  + '">'+_nPageCount+'</a>'; 
    }

    <!-- 下一页 -->
    if (_nCurrIndex < (_nPageCount - 1)){
        var prePage = _sPageName + "_" + (_nCurrIndex + 1) + "." + _sPageExt;
        page+='<a class="last-page" href="' + prePage + '">下一页</a>';
    }

    
    <!-- 打印页码 -->
    $("#page").html(page);
}
</script>
</div>
 -->

<script>

    /*格式化日期*/
    function dateformat(num) {
        if (parseInt(num) < 10) {
            num = '0' + num;
        }
        return num;
    }

    //时间戳转换
    function getMyDate(str) {
        if(typeof str == "undefined" || str == null || str == "" || str == "0"){
            return "";
        }
        var oDate = new Date(str),
        oYear = oDate.getFullYear(),
        oMonth = oDate.getMonth() + 1,
        oDay = oDate.getDate(),
        oHour = oDate.getHours(),
        oMin = oDate.getMinutes(),
        oSen = oDate.getSeconds(),
            oTime = oYear + '-' + dateformat(oMonth) + '-' + dateformat(oDay);//最后拼接时间
      //oTime = oYear +'-'+ dateformat(oMonth) +'-'+ dateformat(oDay) +' '+ dateformat(oHour) +':'+ dateformat(oMin) +':'+dateformat(oSen);//最后拼接时间
      return oTime;
  }

  /**获取市长信箱列表*/

  function getSZXXList(pageIndex, pageSize){
      var intOrganizationID = "10010";//单位id
    var address = "/PublicMail/citizen/ReleaseMailListDistrictJson.aspx"; //信件接口
    var datajson = {"intOrganizationID":intOrganizationID,"currentPage": pageIndex-1, "pageSize": pageSize};
    $.ajax({
        url: address,
        dataType: "json",
        data: datajson,
        type:"get",
        async:"true",
        success: function (data) {
            if(data.code != 100){
                return;
            }else{
                var html="";
          var total = parseInt(data.count);//总记录数
          var totalPages = Math.ceil(total/pageSize);//总页数
          for(var i=0;i<data.data.length;i++){
            var dept = data.data[i].docNumber;//处理机构
            var title = data.data[i].title;//标题
            var url = data.data[i].url; //地址
            var openDate = getMyDate(data.data[i].openDate.replace(/-/g,"/"));//回复时间
            var writeDate = getMyDate(data.data[i].writeDate.replace(/-/g,"/"));//来信时间


            html+='<div class="t-body clearfix"><div class="lf t-title"><a href="'+url+'">'+title+'</a></div><div class="lf t-zh" style="width:159px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">'+dept+'</div><div class="lf t-q-time" style="width:142px;">'+writeDate +'</div><div class="lf t-a-time">'+openDate+'</div></div>';

        }
        $("#szxxlist").html(html);
        var sljs = data.sljs;
                        var bjjs = data.bjjs;
                        $("#slsl").html('<a class="tt2" style="margin-left:10px;color: #1369c0;font-size: 15px;" href="javascript:void(0);">重庆市人力资源和社会保障网'+getMyDate((new Date()).getTime() )+'来信：受理'+sljs+'件  办结'+bjjs+'件</a>');
    }
        //生成分页
        createPage(totalPages, data.data.count, pageIndex,pageSize);
    },error:function(data){
        console.info(data);
    }
})
}


$(function () {
    getSZXXList(1,20);
});



      //分页
      function createPage(totalPages, total, pageIndex,pageSize){
        var str = "";
        if(totalPages<=1){
            return;
        }
    //pageIndex = pageIndex || 1;
    // 1 输出首页和上一页
    // 1.1 当前页是首页
    if(pageIndex == 1){
        str += "<a href='javascript:void(0)' class='first-page'>上一页</a>";
        str += "<a class='active'  href='javascript:void(0)'>1</a>";
    }
    //1.2 当前页不是首页
    else{
        str += "<a class='first-page' href='javascript:void(0)' onclick='getSZXXList("+(pageIndex-1)+","+pageSize+")'>上一页</a>";
        str += "<a class=''  href='javascript:void(0)' onclick='getSZXXList(1,20)'>1</a>";
    }

    // 2 输出中间分页
    var flag1=true;
    var flag2=true;

    for(var i=2; i<=totalPages; i++){
        if(i-pageIndex<2&&pageIndex-i<2||i<3||totalPages-i<2){
            if(pageIndex == i)
                str += "<a  class='active' href='javascript:void(0);'>"+i+"</a>";
            else
                str += "<a   href='javascript:void(0)' class=''  onclick='getSZXXList("+i+","+pageSize+")'>"+i+"</a>";
        }
        else if(i-pageIndex>2&&flag1){
            flag1=false;
            str += "<a  class='' href='javascript:void(0)'>...</a>";
        }
        else if(pageIndex-i>3&&flag2){
            flag2=false;
            str += "<a  class='' href='javascript:void(0)'>...</a>";
        }
    }

    // 3 输出下一页和尾页
    // 3.1 当前页是尾页
    if(pageIndex == totalPages){
        str += "<a  class='last-page' href='javascript:void(0)'>下一页</a>";
    }
    // 3.2 当前页不是尾页
    else{
        str += "<a class='last-page' href='javascript:void(0)' onclick='getSZXXList("+(pageIndex+1)+","+pageSize+")'>下一页</a>";
    }
    $("#page_hd").html(str);
}
</script>

    <div class="empty"></div>

	<script type="text/javascript" src="./js/foot.js"></script>
</body>
</html>



